﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Yipusoft.Common.BLL;

public partial class Combat_SkillList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();
    }
    private void Bind()
    {
        if (Request["ID"] == null || Request["Year"] == null || Request["Month"] == null)
            return;

        DataView dv = SplitPage.ExecuteSQL("Select j.skill,j.FirstScore,n.xwtype,n.bylaw ,case  j.FirstScoreHg when 2 then '合格' when 1 then '不合格' else '未录入' end 'State' ,n.skillName From Job_Score j  join Job_NewSkill n on j.skill=n.skillID and j.sid='" + new Guid(Request["ID"]) + "' and year(StartTime)='" + Request["Year"] + "' and Month(StartTime)='" + Request["Month"] + "' Order By j.FirstScoreHg Desc ").Tables[0].DefaultView;
        this.UserGrid.DataSource = dv;
        this.UserGrid.DataBind();
    }

    protected void UserGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = (e.Row.RowIndex + 1).ToString();
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }
    }

    public string GetState(object obj)
    {
        if (obj == null)
            return "<font color=red>未录入</font>";
        
        return obj.ToString().Equals("合格")? "<font color=green>" + obj + "</font>":  "<font color=red>" + obj + "</font>";               
    
    }

    public string GetScore(object obj, object objType)
    {
        if (obj == null || objType == null)
            return "";
        string ReturnStr = string.Empty;
        if (objType.ToString().Equals("1"))
        {
            try
            {
                ReturnStr = DateTime.Parse(obj.ToString()).ToString("mm分ss秒");
            }
            catch {
                ReturnStr = "00分00秒";
            };
        }
        if (objType.ToString().Equals("2"))
        {
            ReturnStr = obj.ToString() + "个/分";
        }
        if (objType.ToString().Equals("3"))
        {
           
                ReturnStr = obj.ToString();
           
        }

        return ReturnStr;

    }
}
